<?php 
global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } }
      ?>
<div id="sidebar"> 	
<?php /* на главной */ if ( is_home() || is_page() || is_category() || is_search() ) { ?>
<div class="cat2">
<h3>Видео</h3>
</div>
<div class="swidget">
<noindex>
<?php $video = get_option('ultra_video'); echo stripslashes($video); ?>
</noindex>
</div>
<?php } ?>


<div class="cat2">
<h3>Инструменты</h3>
</div>
<div class="swidget">
<span class="rss"><a href="<?php bloginfo('rss2_url'); ?>"><img src="<?php bloginfo('template_directory'); ?>/images/rss.png"  border="0" title="Подпишись на RSS!" alt="rss"></a></span>
	<?php if ($ultra_tw_loc == "Включить") { ?> 
 <?php include (TEMPLATEPATH . '/tw.php'); ?>
<?php } else { ?> <?php } ?> 
 	<form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
		<input type="text" value="поиск на сайте: запрос+enter..." name="s" id="s" onfocus="if (this.value == 'поиск на сайте: запрос+enter...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'поиск на сайте: запрос+enter...';}" />
	</form>  
	<div style="clear:both;"></div> 
</div>


 <?php /* если отдельная публикация */ if ( is_single() ) { ?>
<div class="cat2">
<h3>Самое обсуждаемое</h3>
</div>
<div class="swidget">
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $ultra_most;");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
						<?php $thumb = get_post_meta($post->ID, 'image', $single = true); ?>
<?php 
if($thumb !== '') { ?>
<img src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo $thumb; ?>&w=30&h=30&zc=1&q=30" alt="<?php if($thumb_alt !== '') { echo $thumb_alt; } else { echo the_title(); } ?>" class="img3" />
<?php }
else { echo ''; } ?>	

<b><?php echo $title ?></b>
</a>
<br />
		<span class="meta"> <?php echo $commentcount ?> коммент. </span>

 	<div style="clear:both;"></div>
 
 </li>
<?php } } ?>
</ul>
</div>			
<?php } ?>



 <?php include(TEMPLATEPATH."/latest.php");?> 


<div class="cat2">
<h3>рубрики</h3>
</div>
<div class="swidget">
<?php
$cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none'));
$cat_n = count($cats) - 1;
for ($i=0;$i<$cat_n;$i++):
if ($i<$cat_n/2):
$cat_left = $cat_left.'<li>'.$cats[$i].'</li>';
elseif ($i>=$cat_n/2):
$cat_right = $cat_right.'<li>'.$cats[$i].'</li>';
endif;
endfor;
?>
<ul class="left">
<?php echo $cat_left;?>
</ul>
<ul class="right">
<?php echo $cat_right;?>
</ul>
	<div style="clear:both;"></div>
</div> 
 	<div style="clear:both;"></div>

<div class="cat2">
<h3>Комментарии</h3>
</div>
<div class="swidget">
 <ul>
<?php if(function_exists('get_recent_comments')) { get_recent_comments(); } ?>
</ul>
</div> 

<div class="cat2">
<h3>архивы</h3>
</div>
<div class="swidget">
  <li class="arsip clearfix">
        <ul>
          <?php wp_get_archives('type=monthly'); ?>
        </ul>
             </li>
</div> 		
		  <div style="clear:both;"></div>
	 <?php if ( !function_exists('dynamic_sidebar')
	|| !dynamic_sidebar(1) ) : ?>
		<?php endif; ?>
		
 	<div style="clear:both;"></div>		
	<div class="cat2">
<h3>контроль</h3>
</div>
<div class="swidget">
<?php $stat = get_option('ultra_stat'); echo stripslashes($stat); ?>
</div> 		
</div><!--sidebar-->
<div style="clear:both;"></div> 
